package com.pdg.mcplugin.simpleconomy.dataproviders.bankmembers;

import com.pdg.mcplugin.common.interfaces.TableProviderKey;

public class BankMemberKey implements TableProviderKey{
	public static final String FIELD_NAME = "name";
	public static final String FIELD_MEMBER = "member";
	
	private static final String CREATE_FIELDS = "`"+FIELD_NAME+"` TEXT NOT NULL,`"+FIELD_MEMBER+"` TEXT NOT NULL";
	private static final String INSERT_FIELDS = "`"+FIELD_NAME+"`,`"+FIELD_MEMBER+"`";
	private static final String INSERT_VALUES = "'%s','%s'";
	private static final String WHERE_CLAUSE = "`"+FIELD_NAME+"`='%s' AND `"+FIELD_MEMBER+"`='%s'";
	private static final String DEFAULT_NAME = "";
	private static final String DEFAULT_MEMBER = "";
	private String name;
	private String member;

	public BankMemberKey(String theName, String theMember) {
		setName(theName);
		setMember(theMember);
	}

	@Override
	public String getCreateFields() {
		return CREATE_FIELDS;
	}

	@Override
	public String getInsertFields() {
		return INSERT_FIELDS;
	}

	@Override
	public String getInsertValues() {
		return String.format(INSERT_VALUES,getName(),getMember());
	}

	@Override
	public String getWhereClause() {
		return String.format(WHERE_CLAUSE,getName(),getMember());
	}
	
	public static BankMemberKey defaultInstance(){
		return new BankMemberKey(DEFAULT_NAME,DEFAULT_MEMBER);
	}

	public String getName() {
		return name;
	}

	public void setName(String bankName) {
		this.name = bankName;
	}

	public String getMember() {
		return member;
	}

	public void setMember(String memberName) {
		this.member = memberName;
	}

}
